package com.xzuf.core.ui;

import javax.swing.JMenu;
import javax.swing.JMenuBar;

import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;

/**
 * @author xzgf
 * @since 2008-7-12
 * @version 1.0
 */
public class MenuUI {

	private static final Log logger = LogFactory.getLog(MenuUI.class);
	
	public JMenuBar iniMenu() {
		logger.debug("Begin initialize JMenuBar...");
		JMenuBar jMenuBar = new JMenuBar();
		JMenu jMenuManager = iniMenuManager();
		JMenu jMenuHelp = iniMenuHelp();
		jMenuBar.add(jMenuManager);
		jMenuBar.add(jMenuHelp);
		logger.debug("End initialize JMenuBar...");
		return jMenuBar;
	}
	
	private JMenu iniMenuHelp() {
		JMenu menu = new JMenu("帮助");
		UIAction[] actions = ActionManager.getHelpActions();
		for(int i=0;i<actions.length;i++) {
			menu.add(actions[i]);
		}
		return menu;
	}
	
	private JMenu iniMenuManager() {
		JMenu menu = new JMenu("系统管理");
		UIAction[] actions = ActionManager.getManagerActions();
		for(int i=0;i<actions.length;i++) {
			menu.add(actions[i]);
		}
		return menu;
	}
}
